package org.example.myl.mqtt;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController()
@RequestMapping("/mqtt")
public class MqttController {
    @Resource
    private MQTTConnect mqttConnect;
    @RequestMapping("/test")
    public void test_send() throws MqttException {
//        MQTTConnect mqttConnect = new MQTTConnect();
        mqttConnect.sub("com/iot/init");
        mqttConnect.pub("com/iot/init", "Mr.Qu" + (int) (Math.random() * 100000000));
    }

}
